Skip to main content

LOE_COE Deep Dive Review

app.py

  1. Create Shell Script button Triggers create_shell_script() function.

    • Displays a form with inputs for nodes, GPUs, tasks, account, mail type, email, algorithm, and utility.
      • User provides input and presses the "Create SH file" button
        • Triggers make_sh(*args):
        • Collects form inputs.
        • Constructs SLURM directives and a Python command.
        • Saves the shell script file with the specified configuration.
  2. User presses the "Find buildings affected" button:

    • Note : looks Like COE
    • Triggers water_main():
      • Collects the Asset ID.
      • Calls buildings_affected_by_watermain(asset_id).
        • Displays the list of buildings affected in the Streamlit interface.
          • Connects to the buildings database i.e URI_BLGS_DB = "data/dnv_coe_buildings.db
          • Executes SQL queries to find buildings affected by the specified water main.
          • Merges the results of the queries into a single DataFrame.
          • Displays the affected buildings in the Streamlit interface.
  3. User presses the "check" button:

    • Note : LOE
    • Triggers check():
    • Tests the connection to the database and displays the connection status
    • connects to URI_SQLITE_DB = "data/dnv_coe.db"(should rename to LOE)
    • Displays a success or failure message based on the connection status.
  4. User presses the "check" button:

  • Note : LOE

  • Triggers dataset_for_surv_analysis()

    1. Database Check:

      • Connects to the SQLite database, connects to URI_SQLITE_DB = "data/dnv_coe.db"(should rename to LOE)
      • Checks if the survival table exists.
    2. Load Data:

      • If the survival table exists, loads data from the table.
    3. Process Data:

      • Cleans and processes the dataset, including handling missing values and calculating time-to-event.
    4. Merge Replacement Dates:

      • Loads replacement dates from a CSV file.
      • Merges the replacement dates with the main dataset.
    5. Calculate Duration:

      • Uses study period settings to calculate the duration for survival analysis.
    6. Save Data:

      • Writes the processed data to the survival table in the SQLite database.
      • Optionally saves the data to a CSV file if configured to do so.
  1. User presses the "View Params" button:
  • Note : LOE

  • Triggers view_params()

    • Display Parameters:
    • Uses st.markdown() to display predefined model parameters in the Streamlit interface.
  1. User presses the "Calculate Results" button:
  • Note : doesn't work. LOE??
  • Triggers config(args)

    • Process: Display Spinner:

      • Displays a spinner in the Streamlit interface to indicate processing.

        Load Configuration File:

      • Loads the configuration file (.toml) for the specified utility.

  1. User presses the "View Results" button:

    • Triggers make_scatter(args)
    • Generate Scatter Plots:
      • Uses the make_scatter() function to generate scatter plots based on the results.
    • Display Plots:
      • Displays the generated scatter plots in the Streamlit interface.
  2. User presses the "Scenario Table" button:

    • Triggers scenarios(args)
    • Get Current Run ID:
    • Retrieves the current run ID from the database.
    • If no run ID exists, initializes it to 1. Otherwise, increments the maximum run ID by 1.

    Insert New Scenario Entry:

    • Inserts a new scenario entry into the scenarios table in the database with the new run ID, status (set to 0), and parameters.
  3. User presses the "View Scenario Table" button:

  • Triggers view_scenarios(args)

  • Connect to Database:

    • Establishes a connection to the SQLite database.
  • Query Scenarios Table:

    • Executes a SQL query to fetch all entries from the scenarios table.
  • Display Results:

    • Displays the last five entries from the scenarios table in the Streamlit interface.
    • If the scenarios table is not found, displays a warning message.

ERD Diagrams

     URI_SQLITE_DB = "data/dnv_coe_buildings.db"

alt text

Note : (should rename to LOE)

     URI_SQLITE_DB = "data/dnv_coe.db"

alt text